package com.it.controller;

import com.it.pojo.MyPet;
import com.it.service.MyPetService;
import io.github.resilience4j.circuitbreaker.CircuitBreaker;
import io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

import static io.vavr.control.Try.ofSupplier;

@RestController
@Api("PetFeginController相关的api")
public class PetController {
    private CircuitBreaker circuitBreaker;
    public PetController(CircuitBreakerRegistry registry){
        circuitBreaker  = registry.circuitBreaker("order");
    }

    @Resource
    MyPetService myPetService;
    @RequestMapping("/myPet/findPetAll")
    @ApiOperation(value = "查询所有宠物",notes = "把所有宠物按分类列出")
    public String findPetAll(){
        return myPetService.findPetAll();
    }

    @RequestMapping("/myPet/findPetOne/{id}")
    @ApiOperation(value = "查询单个宠物信息",notes = "根据宠物id查询详细信息")
    public String findPetOne(@PathVariable("id") Integer id){
        return myPetService.findPetOne(id);
    }
}
